package com.qf.team2.netdisc.common.pojo.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Date;
import java.util.Objects;

/**
 * 文件实体类
 *
 * @author Simon_Wong
 * @date 2021/05/20
 * @since 2021/5/20 9:06
 */
@ApiModel("文件实体")
public class Document {

    @ApiModelProperty("文件id")
    private Integer id;

    @ApiModelProperty("文件名")
    private String name;

    @ApiModelProperty("md5")
    private String md5;

    @ApiModelProperty("文件大小")
    private Integer size;

    @ApiModelProperty("用户id")
    private Integer userId;

    @ApiModelProperty(value = "父目录id", notes = "为根目录时，父目录id为null", allowEmptyValue = true)
    private Integer parentId;

    @ApiModelProperty("是否目录")
    private Integer isDirectory;

    @ApiModelProperty("是否根目录")
    private Integer isRoot;

    @ApiModelProperty("绝对路径")
    private String url;

    @ApiModelProperty("是否删除")
    private Integer isDelete;

    @ApiModelProperty("创建日期")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    private Date createTime;

    @ApiModelProperty("修改日期")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    private Date modifyTime;

    public Document() {
    }

    public Document(Integer id, String name, String md5, Integer size, Integer userId, Integer parentId,
                    Integer isDirectory, Integer isRoot, String url, Integer isDelete, Date createTime,
                    Date modifyTime) {
        this.id = id;
        this.name = name;
        this.md5 = md5;
        this.size = size;
        this.userId = userId;
        this.parentId = parentId;
        this.isDirectory = isDirectory;
        this.isRoot = isRoot;
        this.url = url;
        this.isDelete = isDelete;
        this.createTime = createTime;
        this.modifyTime = modifyTime;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMd5() {
        return md5;
    }

    public void setMd5(String md5) {
        this.md5 = md5;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    public Integer getIsDirectory() {
        return isDirectory;
    }

    public void setIsDirectory(Integer isDirectory) {
        this.isDirectory = isDirectory;
    }

    public Integer getIsRoot() {
        return isRoot;
    }

    public void setIsRoot(Integer isRoot) {
        this.isRoot = isRoot;
    }

    public Integer getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(Date modifyTime) {
        this.modifyTime = modifyTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Document document = (Document) o;
        return id.equals(document.id) && name.equals(document.name) && md5.equals(document.md5) && size
                .equals(document.size) && userId.equals(document.userId) && parentId
                .equals(document.parentId) && isDirectory.equals(document.isDirectory) && isRoot
                .equals(document.isRoot) && url.equals(document.url) && isDelete.equals(document.isDelete) && createTime
                .equals(document.createTime) && modifyTime.equals(document.modifyTime);
    }

    @Override
    public int hashCode() {
        return Objects
                .hash(id, name, md5, size, userId, parentId, isDirectory, isRoot, url, isDelete, createTime, modifyTime);
    }

    @Override
    public String toString() {
        return "Document{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", md5='" + md5 + '\'' +
                ", size=" + size +
                ", userId=" + userId +
                ", parentId=" + parentId +
                ", isDirectory=" + isDirectory +
                ", isRoot=" + isRoot +
                ", url='" + url + '\'' +
                ", isDelete=" + isDelete +
                ", createTime=" + createTime +
                ", modifyTime=" + modifyTime +
                '}';
    }
}
